list-[id].vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  8. <!-- 资讯列表 -->
  9. <div class="newsDetail">
  10. <div class="inner">
  11. <div class="innerLeft">
  12. <section class="book_son_right clearfix">
  13. <div class="book_son_right_ul clearfix">
  14. <div class="book_son_right_li clearfix" v-for="(item, index) in newsDetail" :key="index">
  15. <div class="book_son_right_li_img">
  16. <img class="book_son_right_li_img" :src="item.img_url" :title="item.title"
  17. v-if="item.img_url">
  18. </div>
  19. <div class="book_son_right_li_in clearfix">
  20. <h4 class="book_son_right_li_h4 dot1">{{ item.title }}</h4>
  21. <div class="book_son_right_li_dot3 dot3">
  22. {{ item.description }}
  23. </div>
  24. <NuxtLink :href="`/${item.pinyin}/${item.id}.html`" class="book_son_right_li_btn"
  25. :title="item.name">
  26. 查看详情
  27. </NuxtLink>
  28. </div>
  29. </div>
  30. </div>
  31. </section>
  32. <!-- 分页器 -->
  33. <div class="pagination phone_none" v-if="total > 0">
  34. <el-pagination size="small" background layout="prev, pager, next" :total="total" class="mt-4"
  35. :page-size="pageSize" prev-text="上一页" next-text="下一页" @change="changePage" />
  36. </div>
  37. </div>
  38. <div class="innerRight">
  39. <div class="rightMenuTitle">
  40. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  41. </div>
  42. <ul>
  43. <li v-for="(item, index) in bottomMenu" :key="index">
  44. <NuxtLink :to="`/${item.pinyin}/list-1.html`" :title="item.name"
  45. v-if="item.category_id == pageId" class="active">
  46. {{ item.alias }}
  47. </NuxtLink>
  48. <NuxtLink :to="`/${item.pinyin}/list-1.html`" :title="item.name"
  49. v-else-if="item.category_id != pageId">
  50. {{ item.alias }}
  51. </NuxtLink>
  52. </li>
  53. </ul>
  54. </div>
  55. <div style="clear: both;"></div>
  56. <!-- 分页器 -->
  57. <div class="pagination pc_none" v-if="total > 0">
  58. <el-pagination size="small" background layout=" pager " :total="total" class="mt-4" pager-count="5"
  59. :page-size="pageSize" @change="changePage" />
  60. </div>
  61. </div>
  62. </div>
  63. <!-- 广告二 -->
  64. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  65. <!-- 页面底部 -->
  66. <div class="part_2 pc_none">
  67. </div>
  68. <HomeFoot1></HomeFoot1>
  69. <!-- <HomeFoot2></HomeFoot2> -->
  70. </template>
  71. <script setup>
  72. //1.页面依赖 start ---------------------------------------->
  73. import { ElPagination } from 'element-plus'
  74. import { ArrowRight } from '@element-plus/icons-vue'
  75. import { ref, onMounted } from 'vue';
  76. //获得跳转过来的id
  77. const route = useRoute();
  78. //获得当前的完整路径
  79. const fullPath = route.path;
  80. //拆分,取出来中间这一段,然后提取数字部分
  81. const segments = fullPath.split('/');
  82. const targetSegment = segments[2];
  83. const targetSegment1 = segments[1];
  84. //const numberPart = targetSegment.match(/\d+$/)?.[0];
  85. let articleId;
  86. let pageId;
  87. let routeId
  88. let activeId = parseInt(route.params.id);
  89. // console.log('activeId', activeId);
  90. //通过导航路径反向查询导航id
  91. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  92. method: 'GET',
  93. query: {
  94. 'pinyin': targetSegment1+'/'+targetSegment,
  95. },
  96. });
  97. if (getRouteId.code == 200) {
  98. articleId = getRouteId.data.id;
  99. pageId = getRouteId.data.category_id;
  100. } else {
  101. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  102. // console.log("错误位置:通过url路径查询导航池id")
  103. // console.log("后端错误反馈:", getRouteId.message)
  104. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  105. }
  106. //通过导航路径反向查询导航id
  107. const getRouteId1 = await requestDataPromise('/web/getWebsiteRoute', {
  108. method: 'GET',
  109. query: {
  110. 'pinyin': targetSegment1,
  111. },
  112. });
  113. if (getRouteId1.code == 200) {
  114. routeId = getRouteId1.data.category_id;
  115. } else {
  116. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  117. // console.log("错误位置:通过url路径查询导航池id")
  118. // console.log("后端错误反馈:", getRouteId1.message)
  119. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  120. }
  121. //面包屑导航
  122. const parent_name = ref("");
  123. const parent_id = ref("");
  124. const parent_pinyin = ref("");
  125. let getParentNav = async () => {
  126. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  127. method: 'GET',
  128. query: {
  129. 'catid': routeId,
  130. },
  131. });
  132. if (listData.code == 200) {
  133. parent_name.value = listData.data.alias;
  134. parent_id.value = listData.data.parent_id;
  135. parent_pinyin.value = listData.data.aLIas_pinyin;
  136. } else {
  137. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  138. // console.log("错误位置:获取面包屑导航")
  139. // console.log("后端错误反馈:", listData.message)
  140. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  141. }
  142. }
  143. //获得父级栏目详情
  144. getParentNav();
  145. //1.页面依赖 end ---------------------------------------->
  146. //2.页面数据 start ---------------------------------------->
  147. //广告列表
  148. const adList = ref([]);
  149. let adImg1 = ref([]);
  150. let adImg2 = ref([]);
  151. async function getAdData() {
  152. const adData = await requestDataPromise('/web/getWebsiteAdvertisement', { method: 'GET', query: { 'ad_tag': 'PAGE' } });
  153. adList.value = adData.data;
  154. if (adData.code == 200) {
  155. for (let item of adData.data) {
  156. if (item.ad_tag == 'PAGE_0001') {
  157. adImg1.value = item;
  158. }
  159. if (item.ad_tag == 'PAGE_0002') {
  160. adImg2.value = item;
  161. }
  162. }
  163. } else {
  164. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  165. // console.log("错误位置:获取详情页广告列表")
  166. // console.log("后端错误反馈:", adData.message)
  167. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  168. }
  169. }
  170. getAdData();
  171. const newsDetail = ref({})
  172. const bottomMenu = ref([]);
  173. const total = ref(0);//总条数
  174. const page = ref(1);//当前页码
  175. const pageSize = ref(10); //每页显示的条数
  176. async function getPageMenu() {
  177. const mkdata = await requestDataPromise('/web/getWebsiteBookList', {
  178. method: 'GET',
  179. query: {
  180. 'id': pageId,
  181. 'page': page.value,
  182. 'pageSize': pageSize.value,
  183. },
  184. });
  185. bottomMenu.value = mkdata.data.category;
  186. newsDetail.value = mkdata.data.books;
  187. total.value = mkdata.data.count;
  188. }
  189. getPageMenu();
  190. //2.页面数据 end ---------------------------------------->
  191. //3.分页器 start ---------------------------------------->
  192. //分页事件
  193. let changePage = (value) => {
  194. console.log("当前页码", value);
  195. page.value = value;
  196. getPageMenu()
  197. }
  198. //3.分页器 end ---------------------------------------->
  199. //4.设置seo信息 start---------------------------------------->
  200. //4.1 设置seo信息
  201. const setData = await requestDataPromise('/web/getWebsiteFootInfo', {
  202. method: 'GET',
  203. query: {},
  204. });
  205. let seoTitle = setData.data.website_head.title;
  206. let seoDescription = setData.data.website_head.description;
  207. let seoKeywords = setData.data.website_head.keywords;
  208. let seoSuffix = setData.data.website_head.suffix;
  209. let seoName = setData.data.website_head.website_name;
  210. useSeoMeta({
  211. title: seoTitle + "_" + seoSuffix,
  212. meta: [
  213. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  214. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  215. { name: 'viewport', content:"width=device-width,initial-scale=1,user-scalable=no"}
  216. ]
  217. });
  218. //4.设置seo信息 end---------------------------------------->
  219. onMounted(async () => {
  220. //从客户端获取行政职能部门 加快打开速度
  221. const { $webUrl, $CwebUrl } = useNuxtApp();
  222. //广告1
  223. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_page_0001`
  224. const responseAd1 = await fetch(url, {
  225. headers: {
  226. 'Content-Type': 'application/json',
  227. 'Userurl': $CwebUrl,
  228. 'Origin': $CwebUrl
  229. }
  230. });
  231. const resultAd1 = await responseAd1.json();
  232. adImg1.value = resultAd1.data[0];
  233. //广告2
  234. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_page_0002`
  235. const responseAd2 = await fetch(url2, {
  236. headers: {
  237. 'Content-Type': 'application/json',
  238. 'Userurl': $CwebUrl,
  239. 'Origin': $CwebUrl
  240. }
  241. });
  242. const resultAd2 = await responseAd2.json();
  243. adImg2.value = resultAd2.data[0];
  244. })
  245. </script>
  246. <style lang="less" scoped>
  247. @import '@/assets/css/shukanList.less';
  248. </style>
  249. <style lang="less" scoped>
  250. @media screen and (min-width:801px){/*pc*/
  251. .pc_none{display:none;}
  252. }
  253. @media screen and (max-width:800px){/*ipad_phone*/
  254. .newsDetail {margin-top:11px;}
  255. .newsDetail .inner{width:92%;margin:0px auto 11px;overflow:hidden;}
  256. .newsDetail .inner .innerRight{width:24%; }
  257. .newsDetail .inner .innerRight .rightMenuTitle{width:100%;height:auto; background-size:100% 155%; margin-bottom:11px;}
  258. .newsDetail .inner .innerRight .rightMenuTitle a{display:block;width:100%;height:auto;line-height:33px;font-size:14px;text-align:center;}
  259. .newsDetail .inner .innerRight ul{display:block;width:100%;height:auto;}
  260. .newsDetail .inner .innerRight ul li{display:block;width:100%;height:auto;}
  261. .newsDetail .inner .innerRight ul li a {line-height:20px;height:auto;font-size:12px;margin-bottom:5px;padding: 6px 2px;box-sizing:border-box;
  262. border-left: 2px solid #028E21;}
  263. .newsDetail .inner .innerLeft{width:72%;overflow:hidden;margin:0 ;}
  264. .newsDetail .inner .innerLeft .book_son_right{float:none;width:100%;overflow:hidden;margin-bottom:22px;}
  265. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li>.book_son_right_li_img{width:30%;margin-right:4%;height:auto;}
  266. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li>.book_son_right_li_img .book_son_right_li_img{width:100%;height:27vw; }
  267. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_in{width:auto;float:none; }
  268. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_h4{margin-top:0px;font-size:14px;
  269. line-height:20px;
  270. height:40px;
  271. word-break: normal;
  272. white-space: break-spaces;
  273. overflow: hidden;
  274. text-overflow: unset;
  275. display:-webkit-box!important;-webkit-box-orient:vertical;-webkit-line-clamp:2;
  276. }
  277. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_dot3{line-height:20px;height:40px;font-size:14px;-webkit-line-clamp:2;display:none;}
  278. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_btn{
  279. padding:0px 8px;margin-top:8px;height:28px;line-height:28px;font-size:12px;
  280. position:absolute;bottom:0px;left:37%;
  281. }
  282. .newsDetail{margin-bottom:11px;}
  283. .pagination{margin-top:11px;}
  284. .part_2{height:11px;}
  285. .phone_none{display:none;}
  286. }
  287. </style>